﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.IDao;
using Chinaer.Dao.EF;

namespace Chinaer.Dao
{
    public class MenuSubCategoryDAO : Repository, IMenuSubCategoryDAO
    {
        IDao.IMenuSubCategoryDAO MenusubCategoryDAO = new Chinaer.Dao.EF.MenuSubCategoryDAO();
        public bool EnableTrack
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public IList<Model.Entities.Model_MenuSubCategory> Query(string sql, int pageIndex, out int recordCount, int pageSize, params System.Data.SqlClient.SqlParameter[] sqlParams)
        {
            return MenusubCategoryDAO.Query(sql, pageIndex, out recordCount, pageSize, sqlParams);
        }

        public Model.Entities.Model_MenuSubCategory GetByID(string id)
        {
            return MenusubCategoryDAO.GetByID(id);
        }

        public bool Exists(string id)
        {
            return MenusubCategoryDAO.Exists(id);
        }

        public bool Add(Model.Entities.Model_MenuSubCategory entity)
        {
            return MenusubCategoryDAO.Add(entity);
        }

        public bool Update(Model.Entities.Model_MenuSubCategory entity)
        {
            return MenusubCategoryDAO.Update(entity);
        }

        public bool Delete(Model.Entities.Model_MenuSubCategory entity)
        {
            return MenusubCategoryDAO.Delete(entity);
        }

        public bool Delete(string id)
        {
            return MenusubCategoryDAO.Delete(id);
        }

        public int DeleteByIDs(IList<string> listID)
        {
            return MenusubCategoryDAO.DeleteByIDs(listID);
        }

        public List<Model.Entities.Model_MenuSubCategory> GetMenuSubCategoryByMenuCategoryID(string menuCategoryID)
        {
            using (ChinaerContext context = ChinaerContext.GetNewInstance())
            {
                return context.MenuSubCategories.Where(m => m.CategoryID == menuCategoryID).ToList();
            }
        }

        public List<Model.Entities.Model_MenuSubCategory> GetMenuSbCategoryByCategoryIDAndDianPuID(string menuCategoryID, string dianPuID)
        {
            using (ChinaerContext context = ChinaerContext.GetNewInstance())
            {
                return context.MenuSubCategories.Where(m => m.DianPuID == dianPuID && m.CategoryID == menuCategoryID).ToList();
            }
        }
    }
}
